import 'package:flutter/material.dart';
import '../../widgets/AppColors.dart';

class SteelItem extends StatelessWidget {
  final Map<String, dynamic> data;
  final int index;
  SteelItem({super.key, required this.data, this.index = 0});
  List<String> nameList = [
    '钢坯编号',
    '钢坯形状',
    '钢坯规格',
    '进炉时间',
    '出钢时间',
    '氧化烧损率',
    '脱碳百分比'
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.symmetric(vertical: 7.0, horizontal: 6.0),
      decoration: const BoxDecoration(
        color: Colors.transparent, // 背景色
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Row(
            children: [
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
                decoration: BoxDecoration(
                  color: AppColors.isDarkMode
                      ? Color(0xFF2AB6F7).withOpacity(0.2)
                      : Color(0xFFE8F7FF),
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Text(
                  nameList[index],
                  style: TextStyle(fontSize: 13, color: Color(0xFF2AB6F7)),
                ),
              ),
              const SizedBox(width: 13),
              Text(
                index == 0
                    ? data['pdiId'].toString()
                    : index == 1
                        ? data['rTypeC'] == 0
                            ? '圆形'
                            : '方形'
                        : index == 2
                            ? data['aWeight'].toString() +
                                '*' +
                                data['thickness'].toString() +
                                '*' +
                                data['aLength'].toString() +
                                'mm'
                            : index == 3
                                ? data['chargingTime'].toString()
                                : index == 4
                                    ? data['dischargingTime'].toString() !=
                                            'null'
                                        ? data['dischargingTime'].toString()
                                        : '-'
                                    : index == 5
                                        ? (data['burningLoss'].toString() !=
                                                    'null'
                                                ? data['burningLoss'].toString()
                                                : '-') +
                                            '%'
                                        : index == 6
                                            ? (data['decarburation']
                                                            .toString() !=
                                                        'null'
                                                    ? data['decarburation']
                                                        .toString()
                                                    : '-') +
                                                '%'
                                            : '',
                style: TextStyle(fontSize: 15, color: AppColors.textSecondary),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
